cmake_minimum_required(VERSION 3.5)
project(asset_management)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 收集源文件
file(GLOB MAIN_SRC src/main.cpp)
file(GLOB HTTP_SRC src/http/*.cpp)
file(GLOB ASSET_SRC src/asset/*.cpp)
file(GLOB UTILS_SRC src/utils/*.cpp)

# 合并所有源文件
set(ALL_SRC
    ${MAIN_SRC}
    ${HTTP_SRC}
    ${ASSET_SRC}
    ${UTILS_SRC}
)

# 添加可执行文件
add_executable(asset_manager ${ALL_SRC})

# 链接必要的库
if(UNIX)
    target_link_libraries(asset_manager pthread)
endif()

# 添加测试目标
enable_testing()

file(GLOB TEST_HTTP_SRC tests/test_http.cpp)
add_executable(test_http ${TEST_HTTP_SRC} ${HTTP_SRC} ${ASSET_SRC} ${UTILS_SRC})

if(UNIX)
    target_link_libraries(test_http pthread)
endif()

add_test(NAME test_http COMMAND test_http)

file(GLOB TEST_ASSET_SRC tests/test_asset.cpp)
add_executable(test_asset ${TEST_ASSET_SRC} ${ASSET_SRC} ${UTILS_SRC})
add_test(NAME test_asset COMMAND test_asset)

file(GLOB TEST_UTILS_SRC tests/test_utils.cpp)
add_executable(test_utils ${TEST_UTILS_SRC} ${ASSET_SRC} ${UTILS_SRC})
add_test(NAME test_utils COMMAND test_utils)
